#include <stack>
#include "../../lib/list.h"

void printListReverseIteratively(ListNode* head) {
  std::stack<int> helper_stack;
  auto node = head;
  while (node != nullptr) {
    helper_stack.push(node->value);
    node = node->next;
  }
  while (!helper_stack.empty()) {
    auto ele = helper_stack.top();
    helper_stack.pop();
    std::cout << ele << " ";
  }
  std::cout << std::endl;
}

void printListReverseRecursively(ListNode* head) {
  if (head != nullptr) {
    printListReverseRecursively(head->next);
    std::cout << head->value << ' ';
  }
}

int main() {
  std::vector<int> vec = {1, 2, 3, 4, 5, 6};
  auto list_head = CreateList(vec);
  printListReverseIteratively(list_head);
  printListReverseRecursively(list_head);
  std::cout << std::endl;
  DeleteList(list_head);
  return 0;
}
